// import { contextBridge, ipcRenderer } from "electron"
const { contextBridge, ipcRenderer } = require('electron');
contextBridge.exposeInMainWorld('vIpcRenderer', {
  minimize: () => ipcRenderer.send('window-min'),
  maximize: () => ipcRenderer.send('window-maximize'),
  close: () => ipcRenderer.send('window-close'),
  // printSilent: (content: string) => {
  //   if (ipcRenderer) {
  //     ipcRenderer.send("print-silent", content);
  //   } else {
  //     console.warn("Electron IPC not available. Running in browser mode.");
  //     // 这里可以做一个 fallback，比如直接打开新窗口打印
  //     const printWindow = window.open("", "_blank");
  //     if (printWindow) {
  //       printWindow.document.write(content);
  //       printWindow.print();
  //     }
  //   }
  // },
  send: (event) => ipcRenderer.send(event),
  printSilent: (data) => ipcRenderer.send('PRINT_SILENT', data),
  preview: (data) => ipcRenderer.send('PREVIEW', data),
  onWeight: (callback) => ipcRenderer.on('weightInfo', (event, data) => callback(data))
})
